package work.chenbo.springboot.mongo.service;

import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Caching;
import work.chenbo.springboot.mongo.entity.User;

/**
 * @author ChenBo
 * @interfaceName UserMongoService
 * @date 2020/11/20
 */
public interface UserMongoService {

    @Caching(put = {
            @CachePut(cacheNames = "user",key = "'username'+#user.username"),
            @CachePut(cacheNames = "user",key = "'id'+#user.id")
    })
    User addUser(User user);

    @Caching(put = {
            @CachePut(cacheNames = "user",key = "'username'+#user.username"),
            @CachePut(cacheNames = "user",key = "'id'+#user.id")
    })
    User updateUser(User user);
}
